home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-04-27 | 58.8 KB | 2,073 lines |
- TABLE OF CONTENTS
-
- datamaster.library/--overview--
- datamaster.library/--Recognizer--
- datamaster.library/--Tags--
- datamaster.library/dmAddRecoDir
- datamaster.library/dmAddRecoFile
- datamaster.library/dmAddRecoName
- datamaster.library/dmCmpStringC
- datamaster.library/dmCmpStringNC
- datamaster.library/dmCmpTextC
- datamaster.library/dmCmpTextNC
- datamaster.library/dmCopyString
- datamaster.library/dmCopyStringNZ
- datamaster.library/dmCountString
- datamaster.library/dmDupString
- datamaster.library/dmFindStringC
- datamaster.library/dmFindStringNC
- datamaster.library/dmFindTextC
- datamaster.library/dmFindTextNC
- datamaster.library/dmFreeDMHandle
- datamaster.library/dmFreeRecoFile
- datamaster.library/dmFreeRecoList
- datamaster.library/dmGetDMR_Tag
- datamaster.library/dmGetRecoAddr
- datamaster.library/dmLockPrefs
- datamaster.library/dmMatchName
- datamaster.library/dmQueryRecoList
- datamaster.library/dmQueryRecoListNew
- datamaster.library/dmQueryRecoNames
- datamaster.library/dmQueryRecoNamesNew
- datamaster.library/dmReadRecoFile
- datamaster.library/dmRecognize
- datamaster.library/dmRecognizePatt
- datamaster.library/dmRemRecoAddr
- datamaster.library/dmRemRecoName
- datamaster.library/dmScanRecoDir
- datamaster.library/dmTestData
- datamaster.library/dmTestFile
- datamaster.library/dmUnLockPrefs
- datamaster.library/--overview-- datamaster.library/--overview--
-
- This library provides 2 kinds of functions:
-
- ° Those that really deal with recognition,recognizers/filetypes
- manipulations ,etc... dmRecognize(), dmRecognizePatt(), dmTestFile()
- dmTestData() ...
-
- ° Comparison/finding routines useable in your code,even if you don't
- need any of the recognition functions.
-
- Every assembly programmer had to do one day string comparison and such
- routines, which are trivial.
-
- Well here are some powerful functions like:
- dmCmpStringC(),dmCmpStringNC(),dmCmpTextC(),dmCmpTextNC()
- dmFindStringC(),dmFindStringNC(),dmFindTextC(),dmFindTextNC()
- dmMatchName(),dmDupString(),dmCountString() ...
-
- ° The 'classic' convention of all libraries is of course respected:
- A0/A1/D0/D1 will always be used as scratch registers.
- datamaster.library/--Recognizer-- datamaster.library/--Recognizer--
-
- Some miscellaneous things you should know before making a recognizers.
- The main informations are in the --Tags--() section.
-
- You will of course understand more quickly with the provided example sources.
-
-
- * When you create a recognizer, please send it to me for inclusion to
- the main package update. Sending also description of the format, and/or
- the sourcecode would be nice too :)
- If you want to release the recognizer "alone" in a separate archive,
- stick to a "reco_CLASS-Name.lha" template,in "libs/misc" directory, so
- the user can find easily the recognizers on aminet.
-
-
- * The recognizers are 'normal' executable files.That means you can use all
- the hunk types you want.
-
-
- * The file must begin with a DATARECO macro,pointing on the taglist.
- Look at --Tags--() & at the source examples.
-
-
- * Always try to group as many Sub-FileTypes as possible under a single
- Major-FileType. If you think the user can need to recognize more
- precisely some Sub-FileTypes in this Major-FileType, then set the
- RECOB_SubType bit in DMR_Flags, and create an array for the
- DMR_SubTypesTable tag , or use the "old" DMR_Check method, etc etc
- (see example sources)
-
-
- * The DMR_Name tag string must be as close as possible to the recognizer
- FILE name (for user conveniance). (CLASS-name template)
-
-
- * Be VERY careful when making a recognizer, and test it thoroughly, not
- only with 2 or 3 files :-)
- A recognizer that doesn't work correctly can miss "good" files
- (annoying but not dramatical), but, WORSE, it can recognize "bad"
- files. This can perturb all the others recognizers. :-(
-
-
- * The resources the library can give you:
-
- Look in DatamasterBase,you have pointers on:
- dos.library
- utility.library
-
- & --optionally-- reqtools.library
- (always verify if this pointer
- is NOT NULL before using it)
-
- (reqtools.library is not vital for the
- library itself,thats why it can do without)
-
- datamaster.library/--Tags-- datamaster.library/--Tags--
-
-
- These are the tags used in the recognizers.
-
- For convenience, they've been grouped by categories.
-
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Setup flags
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
- DMR_Flags (LONG) (MUST be present!)
-
- * RECOF_CheckData:
- If a DMR_Check routine is available.
- (or if a DMR_SubTypesTable array with 1 or more Data Check
- entries is available)
-
- * RECOF_CheckPatt:
- If a DMR_Pattern stringlist is available.
- (or if a DMR_SubTypesTable array with 1 or more Patterns
- entries is available)
-
-
- * RECOF_SubType:
- Means the recognizer provides Sub-FileTypes.
-
- If a DMR_Check tag is used, its return convention is changed to
- D0 = a string pointer on the sub-filetype (or NULL if no match).
-
- The recognition functions will return this string in the
- optionally filled dmh_SubType entry of the DM_Handle
- structure.
- (and the DMR_Name string in dmh_String, as usual)
-
- If a DMR_SubTypesTable array is used instead , set this flag
- too.
-
-
- * RECOF_DupString:
- Used with RECOB_SubType.
- Means the string returned by DMR_Check is already a
- dmDupString()'d one & that it'll the library's job to free it.
- (the library will use this string directly in the handle in
- fact:no need to dmDupString() it 'again'...everybody's happy :-)
- You should not need to use this.(very special).
-
-
-
- DMR_Name (STRPTR) (MUST be present!)
-
- Points on the MAJOR-Filetype name of this recognizer.
- (remember that you may have as many recognizer files as you want,
- with a same MAJOR-filetype string)
-
- This is the string you'll get in the dmh_String of the DM_Handle
- structure returned from dmRecognize() ,dmRecognizePatt() ,
- dmTestFile(), or dmTestData() if the Checkroutine routines or the
- string matching is successful.
-
- This name is case independant,as all the strings used in the library.
-
- Use a "CLASS-Name" template (ASCII-Text, ANIM-FLI etc....)
-
- This string must be as short & simple as possible,as the user will
- have to type it in in the "recognition associated actions"...So
- keep the 550 chars ultra-precise descriptions for the DMR_Descr
- tag ;-)
-
-
-
- DMR_Descr (STRPTR) (optional) (default is "no description")
-
- A string giving more information about the recognized data.
- Don't make it too long,maybe no one will ever read it ,& it may use
- more memory than the 'useful' checkroutine/patterns ;-)
-
- Anyway,by convention,this description should be a zero-ended
- string,with a maximal size of three 60-chars lines (separated with a
- normal $A CR byte).If you want to print this description,make sure
- you can handle the CR chars...If you don't,make a copy of the
- string & replace the $10 chars with spaces...Of course don't even
- think of modifying the original string :°]
-
-
-
- DMR_Version (LONG) (optional) (default is 1.0)
-
- Version & revision of this recognizer:
-
- higher word:version
- lower word:revision (2 digits max is suitable)
-
- asm example: DMR_version,1<<16+25 ;(= V1.25) : Ver<<16+Rev
-
- You get the version by a simple SWAP.
-
-
-
-
- DMR_DMVersion (LONG) (optional) (default is 0)
-
- Minimal needed version of datamaster.library
-
- This will be checked at the initialization of the recognizer.
-
- The recognizer won't be added if the current datamaster.library is
- not recent enough.
-
-
-
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- The recognition tags
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
- DMR_Check (APTR) (optional)
-
- Points on the checkroutine for real DATA recognition.
-
- INPUT:
- ------
- This routine will get the following registers values:
-
- A0=Address of data to be checked
- D0=Size of data
-
- A2=A0 (Useful for all dmFindStringC()-like functions)
- D2=D0 (===========================================)
-
- A5=A6= Datamaster base
-
-
- As you can see,this gives you all you should need to get to work ;-),
- & A2-D2 are already defined for any FindXXXX call you may need.
-
- You can trash all the registers.
-
- D0 does not need to be the last filled register.
-
-
- THE ROUTINE:
- ------------
- In your routine,you should not modify the data you're testing.It'd be
- Ok to trash a file-header allocated by dmTestFile(),that'll be
- FreeMem()'d just after,but if it's data loaded by the user,& he uses
- a dmRecognize() call,it would be UNBEARABLE to alter this data!!!
- If you NEED to make some changes to the data,well,buffer what
- you changed,& set everything as before once the test is done.
-
- It is highly recommanded NOT to use D0 for the comparisons such as
- " move.l (a0),d0...cmp.l #magic_value,d0 ",because in such cases it's
- extremely tempting to exit the check routine when the comparison is
- successful (!)..the problem is that you leave with D0 set to a
- perfectly unknown value!! :-() .Use D1 instead,this will force you
- to think of branching to a moveq #0,d0/moveq #1,d0 somewhere at the
- end of the test.
- (I experienced this a few times,it's quite annoying to see your
- code SHOULD work & doesn't..."Damn! It's the lib that sucks!" ;-)
-
-
- OUTPUT:
- -------
- The result of the check is in D0.
- Set D0 to NULL if the checking is ****SUCCESSFULL****.
-
- It is the same convention used in all the dmCmpXXXX(),dmFindXXXX(),
- dmMatchName() calls,so you can directly exit with a valid result
- when calling such library functions.
-
- The library will then use the name pointed by the DMR_Name tag as
- MAJOR-Filetype.
-
-
- !!VERY IMPORTANT!!
- ------------------
- The recognizers providing Sub-Filetypes (RECOF_SubType set in
- DMR_Flags) use ANOTHER return convention. They return in d0:
-
- * NULL if Failure (!!!!!)
- * else the address of the Sub-Filetype string.
-
-
-
-
- DMR_Pattern (APTR) (optional)
-
- Points on strings used for the Pattern-matching check.Just put the
- strings one after another,and end this with a $ff byte as terminator.
- DO NOT FORGET this one or a few megabytes of memory will be taken
- in account :-(
-
- example:dc.b "*.commodore",0
- dc.b "*.escom",0
- dc.b "*.viscorp",0
- dc.b $ff
-
- The check will be CASE-INSENSITIVE.
-
- You can use the usual aliases ( see dos/ParsePatternNoCase() ) for
- the patterns,but only use ONE item per string;I mean no '|' multiple
- comparisons.That's not my fault!! It seems a few "|"'d strings cause
- an overflow in the parse buffer.Never mind,do as explained it works
- perfectly like this anyway.
-
-
-
- DMR_SubTypesTable (APTR) (optional) (Lib V2+)
-
- If your recognizer supports Sub-filetypes, you can either use the
- classic DMR_Check with "modified return convention" (RECOF_SubType
- set), or use this powerful table feature.
- (NOTE: This table is the only way to have subtypes with "pattern
- only" checks - logical- )
-
- When this tag is set, it overrides DMR_Check &/or DMR_Pattern.
-
-
- The tag points on an array of the shape:
-
- SubType CheckRoutine, SubType Pattern String , SubType String
-
- APTR , STRPTR , STRPTR
-
-
- * If a CheckRoutine or a Pattern String is not available, set the
- value to -1.
-
- * End the array with _THREE_ NULL values...
-
- * Do not sort the table by alpha-order, but by priority order: the
- most common sub-filetypes must be tested first.
-
- * Checkroutines: Return convention is like for a DMR_Check with
- RECOF_SubType: -> d0= SubType String or NULL if failure.
-
- This can be very useful if a SINGLE checkroutine can handle
- multiple sub-filetypes: it just returns d0 = filetype. But of
- course you MUST fill-in the table with the NAMES of all the
- subtypes (so the user can list them!!!!)
-
- example:
-
- dc.l main_check,blue_pattern,blue_name
- dc.l main_check,red_pattern,red_name
- dc.l main_check,yellow_pattern,yellow_name
- .....
- dc.l 0,0,0
-
- (see the "executable" recognizer source as example)
-
-
- You may need a "processing" of the result of the checkroutines.
- If so, use the optional DMR_CheckRoutineHook.
-
-
- * Patterns: exactly like for DMR_Pattern...
-
-
- So, finally everything could look like this:
-
- dc.l blue_check,-1,blue_name
- dc.l red_check,red_pattern,red_name
- dc.l -1,-1,yellow_name
- dc.l -1,black_pattern,black_name
- .....
- dc.l 0,0,0
-
-
-
-
- DMR_CheckRoutineHook (APTR)
-
- This tag points on a personal routine of yours that will be called
- each time a checkroutine of your DMR_SubTypesTable array returns
- its result.
-
- Then you can "treat" the result if you want (for example, your
- checkroutines may return d0=0 if Ok, and this hook would replace
- this by the corresponding name entry of the table)
-
- The hook gets:
- A0= pointer on the current "line" of the array
- (checkroutine,pattern,subtype name)
- D0= value returned by the current checkroutine.
-
-
- Sounds very complicated, it's very simple in fact.
- Look at the example sources :)
-
-
-
-
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Other important tags
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- DMR_Pri (LONG) (optional)
-
- The priority is a very important parameter.The recognizers are
- called by priority descending order.It is critical for speed,that
- the most probable filetypes be set to a HIGH priority,leaving the
- weird,slow & heavy checked types with basic or low priority.
-
- So please set this tag with care.
-
- Conventions are:
-
- PRI_FREQUENT
- +10 : Very common filetypes (& quickly tested,preferably!)
- (mostly system filetypes:executables,icons...)
-
- PRI_SINGLE
- +5 : Standard priority for 'single' filetypes.
- (by default,recognizers with DMR_RecoNumber=<1 will
- have a pri set to PRI_SINGLE)
-
- PRI_GROUPED
- + 1 : Standard priority for 'grouped' filetypes.
- (by default,recognizers with DMR_RecoNumber>1 will
- have a pri set to PRI_GROUPED)
-
- PRI_GROUPEDSLOW
- -5 : 'Grouped' filetypes having heavy checking routines.
-
- PRI_RARE
- -10 : Rare filetypes (or very slowly tested)
-
-
- PRI_HOOKNAME
- -100 : Set by the library, automatically, for recognizers
- having a DMR_HookName tag.
-
-
- Note: Don't forget that if you omit this tag (or set it to zero!!), the
- library will give it a PRI_SINGLE or PRI_GROUPED priority after
- having checked the number of subtypes (it will count the number of
- entries in the DMR_SubTypesTable array)
-
-
-
-
- DMR_InitRoutine (APTR) (optional)
-
- Points on an initialization routine that will be called when
- the recognizer is loaded & added to the list.
-
- If you need any resource opening (libraries etc),do it here!
-
- WARNING:this routine must use the 'standard' resource opening
- conventions,that's to say return a non-NULL value if
- everything went fine.
-
-
-
- DMR_ExitRoutine (APTR) (optional)
-
- Free all the allocated resources here.This function will be
- called when the recognizer is removed from list.
-
-
-
-
- DMR_Class (LONG) (optional) (default is DMCLASSF_Unknown)
- (Lib V2+)
-
- The class concept is not used for the moment, but I plan to use
- this as "filtering" option in the future.
- So please define correctly this tag.
-
-
- Here are the current classes for the moment:
-
-
- DMCLASSF_UNKNOWN
- DMCLASSF_GRAPHICS
- DMCLASSF_ANIMATION
- DMCLASSF_MUSIC
- DMCLASSF_SAMPLE
- DMCLASSF_PACKED
- DMCLASSF_SYSTEM
- DMCLASSF_MISC
- DMCLASSF_LINK
- DMCLASSF_ASCII
-
-
-
- DMR_HookName (STRPTR) (Lib V2+)
-
- This is a rather special feature.
-
- The ti_data of this tag points on a "target" recognizer name.
-
- Some explanations, with an example.
-
- I needed this tag as I wanted to recognize "CUST" and "RonKlaren"
- music formats. The problem was that such musics are EXECUTABLE
- files (with internal replayer).
-
- The "Executable" recognizer has a PRI_FREQUENT priority, which is
- quite normal. So all the CUST/RK musics were recognized as
- executables! The only solution would have been to give the recognizer
- checking these formats a priority higher than the "executable" one.
-
- But this was NOT acceptable : Executables are frequent, CUST & RK
- are definetely NOT. Why slow down all the checks for such rare
- formats? NO...
-
- So here is the solution I came out with: A kind of "2nd chance",
- with this HookName tag. Such recognizers can make a "HOOK" on a
- target filetype. (here :"executable").
- NOTE: I talk of MAJOR-filetype (i.e. the one of DMR_Name tag)
-
-
- What happens then?
- ~~~~~~~~~~~~~~~~~~
-
- In our example...
- Each time some data is recognized as "executable", the library will
- scan the recognizers list, for recognizers with a lower priority,
- searching for those with 'DMR_HookName=Executable'. They will be
- tested in turn, and if one succeeds, it will "steal" the
- recognition from the "target" recognizer (executable here)
-
- The big advantage is that this "special check" is only made when
- the data is recognized as executable, NOT for just any check.
-
- (-: I hope all this was clear enough :-)
-
-
- About those recognizers
- ~~~~~~~~~~~~~~~~~~~~~~~
- - They are exactly as other recognizers. No difference.
-
- - Their priority is automatically set to PRI_HOOKNAME (-100).
- (this is just before the Generic recognizer (-120) )
-
-
-
-
-
-
- datamaster.library/dmAddRecoDir datamaster.library/dmAddRecoDir
-
- NAME
- dmAddRecoDir -- Adds the RECOGNIZERS of specified Dir to list.
-
- SYNOPSIS
- result = dmAddRecoDir( DirName );
- D0 A0
-
- ULONG dmAddRecoDir( STRPTR DirName );
-
- FUNCTION
- Loads/adds all the recognizers present in the dir (no subdirs
- support)
-
- INPUTS
- DirName - Directory Path (may be NULL,so default LIBS:Recognizers/
- will be used)
-
- RESULT
- result (D0) - NULL if failure
-
- NOTE
- ° No need to use a pair of dmLockPrefs() / dmUnLockPrefs()
-
- ° As datamaster.library accepts more than one recognizer per FILETYPE
- definition, you may reload the same RECOGNIZER as many times as you
- want,the problem being that it WON'T *REPLACE* the previous one,it
- will be ADDED as if it was some kind of complement (which is the aim
- of this ;-).So this function is useful mainly to add facultative
- groups (recognizers/Store/ for example);
-
- Using it 10 times on the same dir will just lead to have 10 times the
- same recognizers in memory,10 times slower etc.... ;-(
-
- BUGS
- No bugs.I just plan in the future to make a kind of checksum to
- recognize (!) the recognizers,& avoid this double-loading.(as they
- can't be distinguished from their filetype name..it's the
- same,yes,but it's licit!!!)
-
- SEE ALSO
- dmScanRecoDir()
-
- datamaster.library/dmAddRecoFile datamaster.library/dmAddRecoFile
-
- NAME
- dmAddRecoFile -- Adds a RECOGNIZER to list.
-
- SYNOPSIS
- Recognizer = dmAddRecoFile( FileName );
- D0 A0
-
- ULONG dmAddRecoFile( STRPTR FileName );
-
- FUNCTION
- Loads/adds the given recognizer file.
-
- INPUTS
- FileName - well,just a filename you know... (Default path is set to
- LIBS:Recognizers/ )
-
- RESULT
- Recognizer (D0) - Address of the loaded segment (REAL addr,NOT BCPL).
- Returns NULL if error.
-
- NOTE
- ° No need to use a pair of dmLockPrefs() / dmUnLockPrefs()
-
- ° As datamaster.library accepts more than one recognizer per FILETYPE
- definition, you may reload the same RECOGNIZER as many times as you
- want,the problem being that it WON'T *REPLACE* the previous one,it
- will be ADDED as if it were some kind of complement (which is the aim
- of this ;-).
-
- [Same remark as in dmAddRecoDir()]
-
- BUGS
- See dmAddRecoDir()
-
- SEE ALSO
- dmAddRecoDir(),dmReadRecoFile(),dmAddRecoName(),dmRemRecoAddr()
-
- datamaster.library/dmAddRecoName datamaster.library/dmAddRecoName
-
- NAME
- dmAddRecoName -- Adds a FILETYPE to memorylist.
-
- SYNOPSIS
- result = dmAddRecoName( RecoName );
- D0 A0
-
- ULONG dmAddRecoName( STRPTR RecoName );
-
- FUNCTION
- Loads/adds all the recognizers files beginning with such a name.
-
- INPUTS
- RecoName - Not really a filename.This is a FILETYPE name,which means
- possibly more than one *file* will match this. for
- instance:"Dummy" as parameter would add
- "Dummy.patt","Dummy.data","Dummy.mylittleAddedDefinitions"
- etc.. (Default path is set to LIBS:Recognizers/ )
-
- RESULT
- result (D0) - NULL if error.
-
- NOTE
- ° No need to use a pair of dmLockPrefs() / dmUnLockPrefs()
-
- ° Same remark as in dmAddRecoDir() etc... for double-loading.
-
- BUGS
- see dmAddRecoDir()
-
- SEE ALSO
- dmRemRecoName()
-
- datamaster.library/dmCmpStringC datamaster.library/dmCmpStringC
-
- NAME
- dmCmpStringC -- Support function
-
- SYNOPSIS
- result, address = dmCmpStringC( UserString, RefString );
- D0 A1 A0 A1
-
- ULONG dmCmpStringC( STRPTR UserString, STRPTR RefString );
-
- FUNCTION
- Compares string with the reference string ,case dependent.
-
- Every programmer had one day to make such trivial routines.So here
- are they,once for all...
-
- INPUTS
- UserString - String to be compared.
-
- RefString - Reference string to match.
-
- RESULT
- result (D0) - returns zero **IF MATCHES** (may seem not so
- conventional but it's logical if you think it in
- assembler..."BEQ" happens when the Zero bit of the CCR is
- set...) note:if matching fails,A0 will be preserved.
-
- address (A1) - (asm users only) if matches,points just after the
- found data
-
- SEE ALSO
- dmCmpStringNC(),dmFindStringC(),dmCmpTextC()
-
- datamaster.library/dmCmpStringNC datamaster.library/dmCmpStringNC
-
- NAME
- dmCmpStringNC -- Support function
-
- SYNOPSIS
- result, address = dmCmpStringNC( UserString, RefString );
- D0 A1 A0 A1
-
- ULONG dmCmpStringNC( STRPTR UserString, STRPTR RefString );
-
- FUNCTION
- Compares string with the reference string ,case independent.
-
- Every programmer had one day to make such trivial routines.So here
- are they,once for all...
-
- INPUTS
- UserString - String to be compared.
-
- RefString - Reference string to match.
-
- RESULT
- result (D0) - returns zero **IF MATCHES** (may seem not so
- conventional but it's logical if you think it in
- assembler..."BEQ" happens when the Zero bit of the CCR is
- set...) note:if matching fails,A0 will be preserved.
-
- address (A1) - (asm users only) if matches,points just after the
- found data
-
- SEE ALSO
- dmCmpStringC(),dmFindStringNC(),dmCmpTextNC()
-
- datamaster.library/dmCmpTextC datamaster.library/dmCmpTextC
-
- NAME
- dmCmpTextC -- Support function
-
- SYNOPSIS
- result, address = dmCmpTextC( UserString, RefString );
- D0 A1 A0 A1
-
- ULONG dmCmpTextC( APTR UserString, STRPTR RefString );
-
- FUNCTION
- Compares text with the reference string ,case dependent.
-
- For example: "HelloWorld" TEXT would match "Hello" string.
-
- Every programmer had one day to make such trivial routines.So here
- are they,once for all...
-
- INPUTS
- UserString - text to be compared.
-
- RefString - Reference string to match.
-
- RESULT
- result (D0) - returns zero **IF MATCHES** (may seem not so
- conventional but it's logical if you think it in
- assembler..."BEQ" happens when the Zero bit of the CCR is
- set...) note:if matching fails,A0 will be preserved.
-
- address (A1) - (asm users only) if matches,points just after the
- found data
-
- SEE ALSO
- dmCmpTextNC(),dmFindTextC(),dmCmpStringC()
-
- datamaster.library/dmCmpTextNC datamaster.library/dmCmpTextNC
-
- NAME
- dmCmpTextNC -- Support function
-
- SYNOPSIS
- result, address = dmCmpTextNC( UserString, RefString );
- D0 A1 A0 A1
-
- ULONG dmCmpTextNC( APTR UserString, STRPTR RefString );
-
- FUNCTION
- Compares text with the reference string ,case independent.
-
- For example: "heLLOWorld" TEXT would match "hELlo" string.
-
- Every programmer had one day to make such trivial routines.So here
- are they,once for all...
-
- INPUTS
- UserString - text to be compared.
-
- RefString - Reference string to match.
-
- RESULT
- result (D0) - returns zero **IF MATCHES** (may seem not so
- conventional but it's logical if you think it in
- assembler..."BEQ" happens when the Zero bit of the CCR is
- set...) note:if matching fails,A0 will be preserved.
-
- address (A1) - (asm users only) if matches,points just after the
- found data
-
- SEE ALSO
- dmCmpTextC(),dmFindTextNC(),dmCmpStringNC()
-
- datamaster.library/dmCopyString datamaster.library/dmCopyString
-
- NAME
- dmCopyString -- Support function
-
- SYNOPSIS
- LastByte = dmCopyString( UserString, Dest );
- A0 A0 A1
-
- APTR dmCopyString( STRPTR UserString, APTR Dest );
-
- FUNCTION
- A simple copystring routine that's all... (wow! a 4 instructions
- routine ;-)
-
- (it includes the final zero of the string)
-
- Just another trivial routine...
-
- INPUTS
- UserString - String to be copied
-
- Dest - Address where to copy the string
-
- RESULT
- LastByte (A0) - Points on the byte following the last
- character.(that's to say on the zero byte).Handy if you want
- to stick another string after this one.
-
- SEE ALSO
- dmCopyStringNZ(),dmDupString(),dmCountString()
-
- datamaster.library/dmCopyStringNZ datamaster.library/dmCopyStringNZ
-
- NAME
- dmCopyStringNZ -- Support function
-
- SYNOPSIS
- LastByte = dmCopyStringNZ( UserString, Dest );
- A0 A0 A1
-
- APTR dmCopyStringNZ( STRPTR UserString, APTR Dest );
-
- FUNCTION
- A simple copystring routine that's all... (wow! a 4 instructions
- routine ;-)
-
- (it DOES NOT include the final zero of the string)
-
- Just another trivial routine...
-
- INPUTS
- UserString - String to be copied
-
- Dest - Address where to copy the string
-
- RESULT
- LastByte (A0) - Points on the byte following the last character.Handy
- if you want to stick another string after this one.
-
- SEE ALSO
- dmCopyString(),dmDupString(),dmCountString()
-
- datamaster.library/dmCountString datamaster.library/dmCountString
-
- NAME
- dmCountString -- Support function
-
- SYNOPSIS
- result = dmCountString( UserString );
- D0 A0
-
- ULONG dmCountString( STRPTR UserString );
-
- FUNCTION
- Counts the number of characters in the string.
-
- Just another trivial routine...
-
- INPUTS
- UserString - String to 'count'
-
- RESULT
- result (D0) - size of the string in bytes (NOT including the final
- zero)
-
- SEE ALSO
- dmCopyString(),dmCopyStringNZ(),dmDupString()
-
- datamaster.library/dmDupString datamaster.library/dmDupString
-
- NAME
- dmDupString -- Support function
-
- SYNOPSIS
- StringAddress, StringSize = dmDupString( UserString );
- A0 D0 A0
-
- APTR dmDupString( STRPTR UserString );
-
- FUNCTION
- A nice function for lazy people like me...It takes your string,gets
- it size, (INCLUDING THE ZERO) allocates the space for it,& copies it
- there...
-
- It can be of some help if you want to do a dmCmpStringNC()-like
- call,but need to modify a bit the string...just duplicate it & work
- on the copy...
-
- INPUTS
- UserString - String to be copied
-
- RESULT
- StringAddress (A0) - Allocated Address (or NULL if failure)
-
- StringSize (D0) - (asm users only) Size allocated for the string.Pass
- this to Exec/FreeMem() when done.Will be NULL is failure.
-
- NOTE
- Don't forget to FreeMem() the string when done,of course.. ;-)
-
- SEE ALSO
- dmCopyString(),dmCopyStringNZ(),dmCountString()
-
- datamaster.library/dmFindStringC datamaster.library/dmFindStringC
-
- NAME
- dmFindStringC -- Support function
-
- SYNOPSIS
- result = dmFindStringC( StartAddress, RefString, ScanSize,
- D0 A0 A1 D0
- DataStart, DataSize );
- A2 D2
-
- ULONG dmFindStringC( APTR StartAddress, STRPTR RefString, ULONG
- ScanSize, APTR DataStart, ULONG DataSize );
-
- FUNCTION
- Finds a String (case sensitive) in a memory zone,starting at a
- particular address.
-
- Note:finding a STRING means it must have a FINAL ZERO.This is much
- less common then TEXT finding I think.
-
- Every programmer had one day to make such trivial routines.So here
- are they,once for all...
-
- INPUTS
- StartAddress - Current address to start finding.
-
- RefString - Reference string to find.
-
- ScanSize - Size of scanning (-1 means all data).StartAddress &
- Scansize values will be automatically maintained within the
- bounds of DataStart->DataStart+DataSize. example:
- FindStringC(15000,refstring,5000,10000,8000).Here you can see
- that Scanzone is 15000->20000 whereas Datazone is
- 10000->18000.So Scanzone will be cut to 15000->18000.
-
- DataStart - Address of the data zone we're searching in.Of course
- DataStart<StartAddress<DataStart+DataSize.
-
- DataSize - Size of the data zone.
-
- RESULT
- result (D0) - returns zero **IF FOUND** (may seem not so conventional
- but it's logical if you think it in assembler..."BEQ" happens
- when the Zero bit of the CCR is set...).In that case,you
- would also get A1 pointing immediately after the found data.
- Anyway,you will get a0 (StartAddress) preserved.
-
- SEE ALSO
- dmFindStringNC(),dmFindTextC(),dmCmpStringC()
-
- datamaster.library/dmFindStringNC datamaster.library/dmFindStringNC
-
- NAME
- dmFindStringNC -- Support function
-
- SYNOPSIS
- result = dmFindStringNC( StartAddress, RefString, ScanSize,
- D0 A0 A1 D0
- DataStart, DataSize );
- A2 D2
-
- ULONG dmFindStringNC( APTR StartAddress, STRPTR RefString, ULONG
- ScanSize, APTR DataStart, ULONG DataSize );
-
- FUNCTION
- Finds a String (case insensitive) in a memory zone,starting at a
- particular address.
-
- Note:finding a STRING means it must have a FINAL ZERO.This is much
- less common then TEXT finding I think.
-
- Every programmer had one day to make such trivial routines.So here
- are they,once for all...
-
- INPUTS
- StartAddress - Current address to start finding.
-
- RefString - Reference string to find.
-
- ScanSize - Size of scanning (-1 means all data).StartAddress &
- Scansize values will be automatically maintained within the
- bounds of DataStart->DataStart+DataSize. example:
- FindStringNC(15000,refstring,5000,10000,8000).Here you can
- see that Scanzone is 15000->20000 whereas Datazone is
- 10000->18000.So Scanzone will be cut to 15000->18000.
-
- DataStart - Address of the data zone we're searching in.Of course
- DataStart<StartAddress<DataStart+DataSize.
-
- DataSize - Size of the data zone.
-
- RESULT
- result (D0) - returns zero **IF FOUND** (may seem not so conventional
- but it's logical if you think it in assembler..."BEQ" happens
- when the Zero bit of the CCR is set...).In that case,you
- would also get A1 pointing immediately after the found data.
- Anyway,you will get a0 (StartAddress) preserved.
-
- SEE ALSO
- dmFindStringC(),dmFindTextNC(),dmCmpStringNC()
-
- datamaster.library/dmFindTextC datamaster.library/dmFindTextC
-
- NAME
- dmFindTextC -- Support function
-
- SYNOPSIS
- result = dmFindTextC( StartAddress, RefString, ScanSize,
- D0 A0 A1 D0
- DataStart, DataSize );
- A2 D2
-
- ULONG dmFindTextC( APTR StartAddress, STRPTR RefString, ULONG
- ScanSize, APTR DataStart, ULONG DataSize );
-
- FUNCTION
- Finds a Text (case sensitive) in a memory zone,starting at a
- particular address.
-
- Note:a 'TEXT' is a 'string' WITHOUT A FINAL ZERO.
-
- Every programmer had one day to make such trivial routines.So here
- are they,once for all...
-
- INPUTS
- StartAddress - Current address to start finding.
-
- RefString - Reference string to find.
-
- ScanSize - Size of scanning (-1 means all data).StartAddress &
- Scansize values will be automatically maintained within the
- bounds of DataStart->DataStart+DataSize. example:
- FindTextC(15000,refstring,5000,10000,8000).Here you can see
- that Scanzone is 15000->20000 whereas Datazone is
- 10000->18000.So Scanzone will be cut to 15000->18000.
-
- DataStart - Address of the data zone we're searching in.Of course
- DataStart<StartAddress<DataStart+DataSize.
-
- DataSize - Size of the data zone.
-
- RESULT
- result (D0) - returns zero **IF FOUND** (may seem not so conventional
- but it's logical if you think it in assembler..."BEQ" happens
- when the Zero bit of the CCR is set...).In that case,you
- would also get A1 pointing immediately after the found data.
- Anyway,you will get a0 (StartAddress) preserved.
-
- SEE ALSO
- dmFindTextNC(),dmFindStringC(),dmCmpTextC()
-
- datamaster.library/dmFindTextNC datamaster.library/dmFindTextNC
-
- NAME
- dmFindTextNC -- Support function
-
- SYNOPSIS
- result = dmFindTextNC( StartAddress, RefString, ScanSize,
- D0 A0 A1 D0
- DataStart, DataSize );
- A2 D2
-
- ULONG dmFindTextNC( APTR StartAddress, STRPTR RefString, ULONG
- ScanSize, APTR DataStart, ULONG DataSize );
-
- FUNCTION
- Finds a Text (case insensitive) in a memory zone,starting at a
- particular address.
-
- Note:a 'TEXT' is a 'string' WITHOUT A FINAL ZERO.
-
- Every programmer had one day to make such trivial routines.So here
- are they,once for all...
-
- INPUTS
- StartAddress - Current address to start finding.
-
- RefString - Reference string to find.
-
- ScanSize - Size of scanning (-1 means all data).StartAddress &
- Scansize values will be automatically maintained within the
- bounds of DataStart->DataStart+DataSize. example:
- FindTextNC(15000,refstring,5000,10000,8000).Here you can see
- that Scanzone is 15000->20000 whereas Datazone is
- 10000->18000.So Scanzone will be cut to 15000->18000.
-
- DataStart - Address of the data zone we're searching in.Of course
- DataStart<StartAddress<DataStart+DataSize.
-
- DataSize - Size of the data zone.
-
- RESULT
- result (D0) - returns zero **IF FOUND** (may seem not so conventional
- but it's logical if you think it in assembler..."BEQ" happens
- when the Zero bit of the CCR is set...).In that case,you
- would also get A1 pointing immediately after the found data.
- Anyway,you will get a0 (StartAddress) preserved.
-
- SEE ALSO
- dmFindTextC(),dmFindStringNC(),dmCmpTextNC()
-
- datamaster.library/dmFreeDMHandle datamaster.library/dmFreeDMHandle
-
- NAME
- dmFreeDMHandle -- Free a handle
-
- SYNOPSIS
- dmFreeDMHandle( Handle );
- A0
-
- VOID dmFreeDMHandle( APTR Handle );
-
- FUNCTION
- For now,the DM_Handle structure consists mostly of the filetype
- string & size.
-
- This function frees the string itself from memory,& the handle
- structure.
-
- INPUTS
- Handle - Handle allocated via dmRecognize(),dmRecognizePatt() or
- dmTestFile(). a NULL value is accepted,for exiting on error
- [a failed dmRecognize() etc...]
-
- RESULT
-
- SEE ALSO
- dmRecognize(),dmRecognizePatt(),dmTestFile()
-
- datamaster.library/dmFreeRecoFile datamaster.library/dmFreeRecoFile
-
- NAME
- dmFreeRecoFile -- Frees data given back by dmReadRecoFile()
-
- SYNOPSIS
- dmFreeRecoFile( SegAddr );
- A0
-
- VOID dmFreeRecoFile( APTR SegAddr );
-
- FUNCTION
- It's more or less an UnLoadSeg...
-
- INPUTS
- SegAddr - Address of the segment loaded via dmReadRecoFile(). May be
- zero.
-
- RESULT
-
- BUGS
- None known
-
- WARNING
- Careful!!! Of course,you must ***NOT*** use dmRemRecoAddr()
- here!!!!!!
-
- SEE ALSO
- dmReadRecoFile()
-
- datamaster.library/dmFreeRecoList datamaster.library/dmFreeRecoList
-
- NAME
- dmFreeRecoList -- Free a RecoList
-
- SYNOPSIS
- dmFreeRecoList( RecoList );
- A0
-
- VOID dmFreeRecoList( Struct RecoList *RecoList );
-
- INPUTS
- RecoList - RecoList got from dmQueryRecoListNew() or
- dmQueryRecoNamesNew() a NULL value is accepted,for exiting on
- error
-
- RESULT
-
- SEE ALSO
- dmQueryRecoListNew(),dmQueryRecoNamesNew()
-
- datamaster.library/dmGetDMR_Tag datamaster.library/dmGetDMR_Tag
-
- NAME
- dmGetDMR_Tag -- Extract a DMR_ Tag value of a recognizer.
-
- SYNOPSIS
- value = dmGetDMR_Tag( Recognizer, DMR_ tag );
- D0 A0 A1
-
- ULONG dmGetDMR_Tag( APTR Recognizer, ULONG DMR_ tag );
-
- FUNCTION
- This function finds the taglist in the recognizer,& performs a kind
- of GetTagData().It will set some tags to particular defaults
-
- Such settings are important for the library's optimal behavior,so do
- not try to get some information by your own means,such as
- GetTagdata().
-
- INPUTS
- Recognizer - Address of the recognizer segment.
-
- DMR_ tag - A ti_tag to find.See definitions in libraries/datamaster.i
-
- RESULT
- value (D0) - ti_data of the tag
-
- WARNING
- You MUST use a dmLockPrefs() before calling this & an dmUnLockPrefs()
- when you finished using the information you got.
-
- BUGS
- None known
-
- datamaster.library/dmGetRecoAddr datamaster.library/dmGetRecoAddr
-
- NAME
- dmGetRecoAddr -- Get ADDRESS of a RECOGNIZER,given its name.
-
- SYNOPSIS
- recognizer = dmGetRecoAddr( Filetype, CurrentAddr );
- D0 A0 A1
-
- APTR dmGetRecoAddr( STRPTR Filetype, APTR CurrentAddr );
-
- FUNCTION
- When you have a FILETYPE name ,got by dmQueryRecoNamesNew() for
- instance,you may want to know how many RECOGNIZERS there are behind
- this single name,& also what they 'look' like (tag-analyzing,info
- printing...).
-
- This function gives you back the 'current' recognizer corresponding
- to the filetype,skipping all those already found in previous calls
- (you have the CurrentAddr that indicates where we got so far).
-
- INPUTS
- Filetype - Name of the Filetype to find.
-
- CurrentAddr - Address of the first entry matching the name,to start
- with. (very easy you'll see what I mean soon
- :).Typically,you should set this to zero to find the 1st
- RECOGNIZER matching this FILETYPE (as already said,one
- filetype may be split in various recognizers).Then,to find
- ALL the recognizers corresponding to the Filetype,just use
- the Address returned by the function in the next call,til it
- returns zero (last one).
-
- RESULT
- recognizer (D0) - Address of the recognizer,or zero if it was the
- last one (or no recognizer at all).
-
- EXAMPLE
- ;extracted & modified from DMcontrol.s
-
- CALLDM dmLockPrefs
-
- ...
-
- lea name,a0
- sub.l a1,a1
- CALLDM dmGetRecoAddr
- tst.l d0
- beq do_NOTFOUND
-
- .another:
- move.l d0,a0
- bsr PrintUnit
-
- lea name,a0
- move.l d0,a1
- CALLDM dmGetRecoAddr
- tst.l d0
- bne.s .another
-
- CALLDM dmUnLockPrefs
-
- ...
-
- WARNING
- You MUST use a dmLockPrefs() before calling this & an dmUnLockPrefs()
- when you finished using the Address you got.
-
- BUGS
- In V1, this function blew up (!) if the current recognizer was
- RemRecoAddr()'ed between two calls. (I had forgotten to handle this,
- so there was an endless search in table :-(
-
- SEE ALSO
- dmRemRecoAddr(),dmRemRecoName()
-
- datamaster.library/dmLockPrefs datamaster.library/dmLockPrefs
-
- NAME
- dmLockPrefs -- Indicate that user is using info on recognizers.
-
- SYNOPSIS
- void = dmLockPrefs( void );
-
-
- VOID dmLockPrefs( VOID void );
-
- FUNCTION
- Increases by one the dmb_LockNest counter of
- DatamasterBase,indicating that one more user reads/uses informations
- in the recognizers,mainly reading the tags.
-
- Locking the preferences prevents the removal (& addition) of the
- recognizers,so you can get information safely from the
- tags,recognizers namelists etc...
-
- It is used internally when recognition functions ( dmRecognize() etc
- ) are working,and you MUST use it when dealing with functions like
- dmQueryRecoListNew() ,dmQueryRecoName().
-
- This is an extremely important function!! Read the Warning paragraph.
-
- INPUTS
- void -
-
- RESULT
- void () -
-
- NOTE
- This function preserves ALL registers (Even the scratch ones)
-
- WARNING
- ° Don't forget to dmUnLockPrefs()!! Otherwise you would prevent the
- library from doing any dynamic changes in its list til next reboot
- which is not very nice..
-
- SEE ALSO
- dmUnLockPrefs()
-
- datamaster.library/dmMatchName datamaster.library/dmMatchName
-
- NAME
- dmMatchName -- Support function
-
- SYNOPSIS
- result = dmMatchName( UserString, Pattern );
- D0 A0 A1
-
- ULONG dmMatchName( STRPTR UserString, STRPTR Pattern );
-
- FUNCTION
- Provides an easy way to use dos.library/MatchPatternNoCase as it does
- all the hard job for you,such as allocating memory for the
- dos.library/ParsePatternNoCase routine that has to be called
- too,etc...
-
- INPUTS
- UserString - String to be compared.
-
- Pattern - Matching pattern. See dos.library/ParsePattern() for the
- patterns definitions.
-
- RESULT
- result (D0) - returns zero **IF MATCHES** (may seem not so
- conventional but it's logical if you think it in
- assembler..."BEQ" happens when the Zero bit of the CCR is
- set...)
-
- NOTE
- Matching is case insensitive,as you had guessed.
-
- WARNING
- The UserString will be UPCASED by dos.library,so please,if you use
- this function in a recognizer,use something like a dmDupString() and
- DO NOT ALTER the initial data as you can't know wether it's
- "trashable" data loaded by a dmTestFile() call,or a **user-loaded
- data** he may legitimely expect to be kept untouched.
-
- BUGS
- Those of dos.library/MatchPatternNoCase,I suppose! (plus some more?)
-
- SEE ALSO
- dmRecognize(),dmRecognizePatt()
-
- datamaster.library/dmQueryRecoList datamaster.library/dmQueryRecoList
-
- NAME
- dmQueryRecoList -- OBSOLETE. Information for this function is
- removed on purpose.
-
- SYNOPSIS
- dmQueryRecoList();
-
-
- void dmQueryRecoList (void);
-
- FUNCTION
- Use dmQueryRecoListNew() instead.
-
- SEE ALSO
- dmQueryRecoListNew()
-
- datamaster.library/dmQueryRecoListNew datamaster.library/dmQueryRecoListNew
-
- NAME
- dmQueryRecoListNew -- Get a list of the RECOGNIZERS currently in
- memory. (V2)
-
- SYNOPSIS
- RecoList = dmQueryRecoListNew( Classes, Flags );
- D0 D0 D1
-
- Struct RecoList *dmQueryRecoListNew( ULONG Classes, ULONG Flags );
-
- FUNCTION
-
- The library keeps a list of all the recognizer segments currently in
- memory.
-
- This list is sorted by PRIORITY,for efficiency.This function gives
- you back this same list,but ALPHA-SORTED.So you have the addresses of
- all the recognizers in memory,so you'll be able to get info on
- them,remove them from memory,etc, with the dedicated functions.
-
- you'll get in the structure:
-
- rl_NumRecos:the number of RECOGNIZERS in memory
-
- rl_RecoList:here is an address table pointing on all the first
- segments of the recognizers.
-
- The list ends with a zero LONG.
-
- INPUTS
- Classes - not used yet, set it to NULL.
-
- Flags - not used yet, set it to NULL.
-
- RESULT
- RecoList (D0) - RecoList structure. (NULL if no memory)
-
- NOTE
- According to this library's 'philosophy',you may have more than one
- Recognizer *file/segment* for a SAME *filetype*.
-
- Getting direct SegmentAddresses of the recognizers will mainly be
- used for getting all the infos from the DMR_ tags (see the concerned
- support functions)
-
- [These addresses are REAL ones,NOT BCPL]
-
- WARNING
- You MUST use a dmLockPrefs() before calling this & an dmUnLockPrefs()
- when you finished your job with the addresses.
-
- Of course , don't forget to free the structure with a
- dmFreeRecoList().
-
- BUGS
- None known
-
- SEE ALSO
- dmQueryRecoNamesNew(),dmFreeRecoList(),dmGetDMR_Tag(),dmRemRecoAddr()
-
- datamaster.library/dmQueryRecoNames datamaster.library/dmQueryRecoNames
-
- NAME
- dmQueryRecoNames -- OBSOLETE. Information for this function is
- removed on purpose.
-
- SYNOPSIS
- dmQueryRecoNames();
-
-
- void dmQueryRecoNames (void);
-
- FUNCTION
- Use dmQueryRecoNamesNew() instead.
-
- SEE ALSO
- dmQueryRecoNamesNew()
-
- datamaster.library/dmQueryRecoNamesNew datamaster.library/dmQueryRecoNamesNew
-
- NAME
- dmQueryRecoNamesNew -- Get a list of the FILETYPES currently in
- memory. (V2)
-
- SYNOPSIS
- RecoList = dmQueryRecoNamesNew( Classes, Flags );
- D0 D0 D1
-
- Struct RecoList *dmQueryRecoNamesNew( ULONG Classes, ULONG Flags );
-
- FUNCTION
- Similar to dmQueryRecoListNew(),but here you'll get an alpha-sorted
- list of all the FILETYPES NAMES...This gives you access to functions
- that deal with global filetypes names,not caring to know how many
- recognizers really correspond to a particular filetype.It's also
- cleaner when you want to display the filetypes.You could have the
- same result by calling dmQueryRecoListNew(),& then getting each
- recognizer's name by dmGetDMR_Tag().But you'd be obliged to handle
- all the multiple recognizer entries for a same filetype,leading you
- wether to check this,or print many times the same name...Hmmm...not
- so nice! So this function if for you.
-
- you'll get in the structure:
-
- rl_NumRecos:the number of RECOGNIZERS in memory
-
- rl_RecoList:here is an address table pointing on all the first
- segments of the recognizers.
-
- The list ends with a zero LONG.
-
- INPUTS
- Classes - not used yet, set it to NULL.
-
- Flags - not used yet, set it to NULL.
-
- RESULT
- RecoList (D0) - RecoList structure. (NULL if no memory)
-
- NOTE
- According to this library's 'philosophy',you may have more than one
- Recognizer *file/segment* for a SAME *filetype*.
-
- WARNING
- You MUST use a dmLockPrefs() before calling this & an dmUnLockPrefs()
- when you finished manipulating the infos you got.
-
- Of course , don't forget to free the structure with a
- dmFreeRecoList().
-
- BUGS
- None known
-
- SEE ALSO
- dmQueryRecoListNew(),dmFreeRecoList(),dmRemRecoName()
-
- datamaster.library/dmReadRecoFile datamaster.library/dmReadRecoFile
-
- NAME
- dmReadRecoFile -- Loads a recognizer file
-
- SYNOPSIS
- Recognizer = dmReadRecoFile( FileName );
- D0 A0
-
- APTR dmReadRecoFile( STRPTR FileName );
-
- FUNCTION
- Loads the recognizer but doesn't initialize it,nor link it to the
- list.
-
- It's just for an information purpose (from the DMR_ tags)
-
- INPUTS
- FileName - a filename,yes yes... (Default path is set to
- LIBS:Recognizers/ )
-
- RESULT
- Recognizer (D0) - Address of the loaded segment (REAL addr,NOT BCPL).
- Returns zero if error.
-
- BUGS
- None known
-
- SEE ALSO
- dmFreeRecoFile(),dmAddRecoFile()
-
- datamaster.library/dmRecognize datamaster.library/dmRecognize
-
- NAME
- dmRecognize -- Analyse a portion of memory
-
- SYNOPSIS
- DM_Handle = dmRecognize( Addr, Size );
- D0 A0 D0
-
- APTR dmRecognize( APTR Addr, ULONG Size );
-
- FUNCTION
- Asks all the recognizers in memory (calling the DMR_Check tag
- function) to recognize the filetype of this data.If none succeeds,you
- will get a 'generic' filetype.
-
- INPUTS
- Addr - Address of data to be checked.
-
- Size - Size of the check...
-
- RESULT
- DM_Handle (D0) - address of a DM_Handle structure.In this
- structure,you'll find a pointer to the filetype in the
- dmh_String pointer.Each time a caller accesses one of the
- recognition functions,the library DUPLICATES the filetype
- name & creates the handle. This uses a few bytes but it's
- very convenient,as caller gets an 'independent' string: it's
- a copy,so the recognizer which this string came from can be
- freed without problem while you still have a hand on YOUR
- string! Dont' forget to dmFreeDMHandle() the handle you
- got... Starting with library V2, one additional field in the
- handle: - dmh_SubType: An additional subtype string, if
- available (else will be NULL). For a more accurate
- recognition of the data. PLEASE PROVIDE MATCHING TESTS FOR
- THIS STRING TOO!! This function will return NULL if memory
- can't be allocated for handle.
-
- EXAMPLE
-
-
- lea data,a0
- move.l #5000,d0
- CALLDM dmRecognize
- tst.l d0 ;<Get filetype name & print it for example>
- beq.s .error
- move.l d0,a4 ;get the valid DMhandle
- move.l d0,handle
- move.l dmh_String(a4),a0 ;get the filetype string...
- bsr PrintTheString ;print it with your routine
- tst.l dmh_SubType(a4)
- beq.s .nosubtype
- move.l dmh_SubType(a4),a0 ;print subtype if available
- bsr PrintTheString
-
- .nosubtype:
- .... ;etc...
-
- move.l handle,a0 ;don't forget to free the handle
- CALLDM dmFreeDMHandle
-
- handle: dc.l 0 ;store pointer to DM handle here.
- data: (what is it I can't guess,but I hope the library will ;-)
-
- BUGS
- None known
-
- SEE ALSO
- dmRecognizePatt(),dmTestFile(),dmTestData(),dmFreeDMHandle()
-
- datamaster.library/dmRecognizePatt datamaster.library/dmRecognizePatt
-
- NAME
- dmRecognizePatt -- Analyze a name
-
- SYNOPSIS
- DM_Handle = dmRecognizePatt( Name );
- D0 A0
-
- APTR dmRecognizePatt( STRPTR Name );
-
- FUNCTION
- Asks all the recognizers in memory (Matching all their DMR_Pattern
- lists) to recognize the filetype of this data.If none succeeds,you
- will get a 'generic' filetype.
-
- INPUTS
- Name - May be a real filename,or a dummy one,no matter,as only
- Pattern-matching will be done here. Note:this name will be
- DOS/FileParted().
-
- RESULT
- DM_Handle (D0) - address of a DM_Handle structure. See dmRecognize()
- for full information on the DMhandle. This function will
- return NULL if memory can't be allocated for handle.
-
- EXAMPLE
-
-
- lea data,a0
- CALLDM dmRecognizePatt
- tst.l d0 ;<Get filetype name & print it for example>
- beq.s .error
- move.l d0,a4 ;get the valid DMhandle
- move.l d0,handle
- move.l dmh_String(a4),a0 ;get the filetype string...
- bsr PrintTheString ;print it with your routine
- tst.l dmh_SubType(a4)
- beq.s .nosubtype
- move.l dmh_SubType(a4),a0 ;print subtype if available
- bsr PrintTheString
-
- .nosubtype:
- .... ;etc...
- move.l handle,a0 ;don't forget to free the handle
- CALLDM dmFreeDMHandle
-
- handle: dc.l 0 ;store pointer to DM handle here.
- data: dc.b "mod.survive",0 ;surely a "MUSIC-Ptk&Clones",no? Hmm...
-
- BUGS
- None known
-
- SEE ALSO
- dmRecognize(),dmTestFile(),dmTestData(),dmFreeDMHandle()
-
- datamaster.library/dmRemRecoAddr datamaster.library/dmRemRecoAddr
-
- NAME
- dmRemRecoAddr -- Frees a single recognizer from list.
-
- SYNOPSIS
- result = dmRemRecoAddr( address );
- D0 A0
-
- ULONG dmRemRecoAddr( APTR address );
-
- FUNCTION
- Calls the DMR_ExitRoutine of the recognizer & frees it from
- memory/list.
-
- INPUTS
- address - Address of the segment,obtained from the rl_RecoList table
- [filled by dmQueryRecoListNew() ],or from a single
- dmAddRecoFile(),dmGetRecoAddr() (may be NULL)
-
- RESULT
- result (D0) - zero if error (for the moment,failure only happens if
- somebody has locked the recognizerlist)
-
- NOTE
- ° No need to use a pair of dmLockPrefs() / dmUnLockPrefs()
-
- ° This function does NOT check the given address.Let's consider you
- make your code clean enough to give a correct pointer ;-)
-
- BUGS
- none known
-
- SEE ALSO
- dmAddRecoFile()
-
- datamaster.library/dmRemRecoName datamaster.library/dmRemRecoName
-
- NAME
- dmRemRecoName -- Frees a FILETYPE from list
-
- SYNOPSIS
- result = dmRemRecoName( Name );
- D0 A0
-
- ULONG dmRemRecoName( STRPTR Name );
-
- FUNCTION
- Finds & frees all the RECOGNIZERS of the list matching this FILETYPE
- name.
-
- INPUTS
- Name - Name of the filetype to free. If string is "all" (case
- insensitive) then ALL the filetypes will be freed. Note:In
- fact only the INTERNAL recognizers will remain.
-
- RESULT
- result (D0) - zero if error (for the moment,failure only happens if
- somebody has locked the recognizerlist)
-
- NOTE
- No need to dmLockPrefs() / dmUnLockPrefs()
-
- BUGS
- None known
-
- SEE ALSO
- dmAddRecoName()
-
- datamaster.library/dmScanRecoDir datamaster.library/dmScanRecoDir
-
- NAME
- dmScanRecoDir -- Flushes all current recognizers & loads contents of
- given directory
-
- SYNOPSIS
- result = dmScanRecoDir( DirName );
- D0 A0
-
- ULONG dmScanRecoDir( STRPTR DirName );
-
- FUNCTION
- Flushes all current external recognizers from memory,then scans the
- given directory for new recognizers.
-
- INPUTS
- DirName - Directory Path (may be NULL,so default LIBS:Recognizers/
- will be used)
-
- RESULT
- result (D0) - NULL if failure
-
- NOTE
- No need to use a pair of dmLockPrefs() / dmUnLockPrefs()
-
- BUGS
- None known
-
- SEE ALSO
- dmAddRecoDir()
-
- datamaster.library/dmTestData datamaster.library/dmTestData
-
- NAME
- dmTestData -- Determine the filetype of a given data buffer. (V2)
-
- SYNOPSIS
- DM_Handle = dmTestData( Addr, Size, Flags, Name );
- D0 A0 D0 D1 A1
-
- APTR dmTestData( APTR Addr, ULONG Size, ULONG Flags, STRPTR Name );
-
- FUNCTION
- This is a more powerful function than dmRecognize() and
- dmRecognizePatt().
-
- It's main purpose is to be able to make both IN THE SAME TIME. (if
- you give all the parameters).
-
- What would this do? Well, it calls both functions and keeps the
- "best" DM_Handle (i.e the one that is not "Generic" [=failure]).
-
- -> If Addr & Size are non-NULL, a dmRecognize() will be possible.
-
- -> If Name is non-NULL, a dmRecognizePatt() will be possible.
-
- INPUTS
- Addr - Address of the data to check. (or NULL)
-
- Size - Size for the check... (or NULL)
-
- Flags - See below
-
- Name - Optional filename (or NULL if not available) (The string will
- be DOS/FileParted() automatically)
-
- RESULT
- DM_Handle (D0) - address of a DM_Handle structure. See dmRecognize()
- for full information on the DMhandle. This function will
- return NULL if memory can't be allocated for handle.
-
- FLAGS
- Flags definitions:
-
- ° RECOF_PattPriority : Useful only when all parameters are
- set (means both dmRecognize() & dmRecognizePatt() will be
- used.)
-
- Normally "data" check beats "pattern" check.Setting this will
- reverse the situation. Conclusion: if both "data" &
- "pattern" checks return a "non-generic" filetype, the
- "pattern" handle would here be used instead of the "data"'s.
- (can be useful in some cases, if you have recognizers with
- lots of pattern checks and poor data checks.). User MUST
- have control on this.
-
- NOTE: Anyway, user HAS control on this, thanx to the DM_PattPri
- Env-variable! :)
-
- EXAMPLE
-
- example:
- ...
- lea BufferAddr,a0
- move.l #BufferSize,d0
- move.l #RECOF_CheckData+RECOF_CheckPatt,d1
- lea name,a1
- CALLDM dmTestData
- tst.l d0 ;<Get filetype name & print it for example>
- beq.s .error
- move.l d0,a0
- move.l d0,handle
- ... ;<use,print,etc the filetype string>
- move.l handle,a0 ;don't forget to free the handle
- CALLDM dmFreeDMHandle
-
- handle: dc.l 0
- name: dc.b "DH1:Mydir/BlahBlah/file",0
-
- NOTE
- THAT is a nice & simple function (to use I mean ;-)),don't you think?
-
- BUGS
- None known
-
- SEE ALSO
- dmRecognize(),dmRecognizePatt(),dmTestFile()
-
- datamaster.library/dmTestFile datamaster.library/dmTestFile
-
- NAME
- dmTestFile -- Determine the filetype of a given file.
-
- SYNOPSIS
- DM_Handle = dmTestFile( Name, Size, Flags );
- D0 A0 D0 D1
-
- APTR dmTestFile( STRPTR Name, ULONG Size, ULONG Flags );
-
- FUNCTION
- Gets the file type,by any means!
-
- INPUTS
- Name - Name of the file to analyze.Depending of the flags given,this
- string may be just a name,or a real existing path.Anyway the
- string will be DOS/FileParted() so you won't have to bother
- to do it.
-
- Size - Loading size for filetype-analyzing.Needed only if the
- RECOB_CheckData bit is set. (-1 means whole file)
-
- Flags - See flags
-
- RESULT
- DM_Handle (D0) - address of a DM_Handle structure. See dmRecognize()
- for full information on the DMhandle. This function will
- return NULL if memory can't be allocated for handle.
-
- FLAGS
- Flags definitions:
-
- ° RECOF_CheckData: verify REALLY the data,so will need to
- load a part of the file.
-
- ° RECOF_CheckPatt: verify only the filename pattern.Surely
- much faster than Checkdata but also less accurate ;(.Can be
- used for 'virtual' filenames.
-
- ° RECOF_XPKload : use XPKRead() instead of the 'classic' DOS
- function. So,no need to be an xdata client for your
- application.The obvious advantage of this is to recognize
- data even if the file is xpk-crunched! It's always a pity
- when you get a result such as 'xpk packed' or 'unknown' :-)
- This makes it better...
-
- ° RECOF_PattPriority : Useful only if RECOF_CheckData &
- RECOF_CheckPatt are both set.
-
- Normally "data" check beats "pattern" check.Setting this will
- reverse the situation. (can be useful in some cases, if you
- have recognizers with lots of pattern checks and poor data
- checks.). User MUST have control on this.
-
- Note:RECOB_CheckData & RECOB_CheckPatt bits may be both
- set;in that case dmRecognize() will be called first,& if it
- 'fails' (means it gets a 'Generic' filetype),then
- dmRecognizePatt() will be used. Conclusion: if both "data" &
- "pattern" checks return a "non-generic" filetype, the
- "pattern" handle would here be used instead of the "data"'s.
-
- EXAMPLE
-
- ;This will xpk unpack 5000 bytes of the file
- ;do a dmRecognize() on them,& if it gets a 'generic' filetype,
- ;then a dmRecognizePatt() will be tried.
- example1:
- ...
- lea name,a0
- move.l #5000,d0
- move.l #RECOF_CheckData+RECOF_CheckPatt+RECOF_XPKload,d1
- CALLDM dmTestFile
- tst.l d0 ;<Get filetype name & print it for example>
- beq.s .error
- move.l d0,a0
- move.l d0,handle
- ... ;<use,print,etc the filetype string>
- move.l handle,a0 ;don't forget to free the handle
- CALLDM dmFreeDMHandle
-
- handle: dc.l 0
- name: dc.b "DH1:Mydir/BlahBlah/file",0
-
- ;This will only analyze the name pattern,& will
- ;of course get a "Icon" filetype
- example2:
- ...
- lea name,a0
- move.l #RECOF_CheckPatt,d1
- CALLDM dmTestFile
- tst.l d0 ;<Get filetype name & print it for example>
- beq.s .error
- move.l d0,a0
- move.l d0,handle
- ...
- move.l handle,a0 ;don't forget to free the handle
- CALLDM dmFreeDMHandle
-
- handle: dc.l 0
- name: dc.b "ReallyDummy:DummyDummyDummy.info",0
-
- NOTE
- THAT is a nice & simple function (to use I mean ;-)),don't you think?
-
- BUGS
- None known
-
- SEE ALSO
- dmRecognize(),dmRecognizePatt(),dmTestData()
-
- datamaster.library/dmUnLockPrefs datamaster.library/dmUnLockPrefs
-
- NAME
- dmUnLockPrefs -- Indicate that user finished using info of
- recognizers.
-
- SYNOPSIS
- void = dmUnLockPrefs( void );
-
-
- VOID dmUnLockPrefs( VOID void );
-
- FUNCTION
- Decreases by one the dmb_LockNest counter of
- DatamasterBase,indicating that user finished reading/using
- informations in the recognizers (mainly tags)
-
- This is an extremely important function!! Read the Warning paragraph.
-
- INPUTS
- void -
-
- RESULT
- void -
-
- NOTE
- This function preserves ALL registers (Even the scratch ones)
-
- WARNING
- ° Don't forget to dmUnLockPrefs()!! Otherwise you would prevent the
- library from doing any dynamic changes in its list til next reboot
- which is not very nice..
-
- SEE ALSO
- dmLockPrefs()
-
-